<!DOCTYPE html>
<html lang="zh">
<head>
	<th:block th:include="include :: header('文件上传')" />
	<th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                    	<div class="form-group">
                            <label class="font-noraml">模板上传</label>
	                        <div class="file-loading">
					            <input class="file" type="file" id="file" name="file" multiple data-min-file-count="1" data-theme="fas">
					        </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script type="text/javascript">
    $(document).ready(function () {
        $("#fileinput-demo-1").fileinput({
            'theme': 'explorer-fas',
            'uploadUrl': '/company/relation/upload',
            overwriteInitial: false,
            initialPreviewAsData: true,
            initialPreview: [
                "/img/profile.jpg"
            ]
        });
    });
    </script>
    	<script type="text/javascript">
		var prefix = ctx + "company/relation";
	    
		$("#form-post-add").validate({
		    focusCleanup: true
		});
		
		function submitHandler(){
		    var type = "file";          //后台接收时需要的参数名称，自定义即可
		    var id = "file";            //即input的id，用来寻找值
		    var formData = new FormData();
		    formData.append(type, $("#"+id)[0].files[0]);    //生成一对表单属性
		    $.ajax({
		        type: "POST",           //因为是传输文件，所以必须是post
		        url: '/company/relation/upload',         //对应的后台处理类的地址
		        data: formData,
		        processData: false,
		        contentType: false,
		        success: function (result) {
		        	$.modal.disable();
		            $.operate.saveSuccess(result);
		           // $.operate.successCallback(result);
		        }
		    });
		    $.modal.closeLoading();
		}

		
	</script>
</body>
</html>
